//package com.naiterui.ehp.bs.recommend.dao.impl;
//
//import java.util.ArrayList;
//import java.util.Date;
//import java.util.HashMap;
//import java.util.List;
//import java.util.Map;
//import java.util.Set;
//import java.util.stream.Collectors;
//
//import org.apache.commons.collections4.CollectionUtils;
//import org.springframework.stereotype.Repository;
//
//import com.naiterui.common.repository.hibernate.DefaultBaseDaoImpl;
//import com.naiterui.ehp.bp.utils.lang.StringUtil;
//import com.naiterui.ehp.bs.recommend.bean.DrMedicationRecomInfo;
//import com.naiterui.ehp.bs.recommend.dao.IMedicationRecomInfoDao;
//
///**
// * 推荐用药处方信息DAO
// *
// * @author wangchuan
// * @Date 2017年7月28日
// * @since V2.9.0
// */
//@Repository
//public class MedicationRecomInfoDaoImpl extends DefaultBaseDaoImpl<DrMedicationRecomInfo, Long> implements IMedicationRecomInfoDao {
//
//    @Override
//    public DrMedicationRecomInfo getRecomInfoByRecomId(Long recommendId) {
//        String hql = " from DrMedicationRecomInfo where recommendId=? ";
//        List<DrMedicationRecomInfo> list = super.find(hql, recommendId);
//        if (list != null && list.size() > 0) {
//            return list.get(0);
//        }
//        return null;
//    }
//
//
//    @Override
//    public DrMedicationRecomInfo getRecomInfoByRecomIdWrite(Long recommendId) {
//        return this.getRecomInfoByRecomId(recommendId);
//    }
//
//    /**
//     * @param recommendIdSet
//     *
//     * @return
//     *
//     * @Date 2017年12月20日
//     * @see IMedicationRecomInfoDao#getRecomInfoByRecomIds(java.util.Set)
//     * @since 2.14
//     */
//    @Override
//    public List<DrMedicationRecomInfo> getRecomInfoByRecomIds(Set<Long> recommendIdSet) {
//        if (CollectionUtils.isNotEmpty(recommendIdSet)) {
//            String idsStr = StringUtil.convertCollection(recommendIdSet);
//            return super.find("from DrMedicationRecomInfo where recommendId in (" + idsStr + ")");
//        }
//        return new ArrayList<>();
//    }
//
//    @Override
//    public Map<Long, DrMedicationRecomInfo> getRecomInfoMap(Set<Long> recomIds) {
//        if (CollectionUtils.isNotEmpty(recomIds)) {
//            String idsStr = StringUtil.convertCollection(recomIds);
//            List<DrMedicationRecomInfo> lists = super.find("from DrMedicationRecomInfo where recommendId in (" + idsStr + ")");
//            return lists.stream().collect(Collectors.toMap(DrMedicationRecomInfo::getRecommendId, o -> o));
//        }
//        return new HashMap<>();
//    }
//
//    @Override
//    public void updateDoctorSignStatus(Long recomId, Integer status, Date signTime) {
//        if (signTime == null) {
//            String sql = "update dr_medication_recom_info set doctor_sign_status=?, changed_at=now(),changed_by='signCallback' where recommend_id=?";
//            super.executeSQL(sql, status, recomId);
//        } else {
//            String sql = "update dr_medication_recom_info set doctor_sign_status=?, doctor_sign_time=?, changed_at=now(),changed_by='signCallback' where recommend_id=?";
//            super.executeSQL(sql, status, signTime, recomId);
//        }
//    }
//
//    @Override
//    public void updatePharmacistSignStatus(Long recomId, Integer status, Date signTime) {
//        if (signTime == null) {
//            String sql = "update dr_medication_recom_info set pharmacist_sign_status=?, changed_at=now(), changed_by='signCallback' where recommend_id=?";
//            super.executeSQL(sql, status, recomId);
//        } else {
//            String sql = "update dr_medication_recom_info set pharmacist_sign_status=?, pharmacist_sign_time=?, changed_at=now(),changed_by='signCallback' where recommend_id=?";
//            super.executeSQL(sql, status, signTime, recomId);
//        }
//    }
//}
